﻿// 功能：TRIVERTEX结构包含颜色信息和位置信息。API函数GradientFill用到此结构体
// 描述：
// 作者：温伟鹏
// 日期：2010/6/8 14:45:18

using System;
using System.Drawing;

namespace MeizuSDK.Drawing
{
    /// <summary>
    /// TRIVERTEX结构包含颜色信息和位置信息。API函数GradientFill用到此结构体
    /// </summary>
    public struct TRIVERTEX
    {
        /// <summary>
        /// 获取或设置顶点X坐标
        /// </summary>
        public int x;
        /// <summary>
        /// 获取或设置顶点Y坐标
        /// </summary>
        public int y;
        /// <summary>
        /// 获取或设置顶点的RGB颜色中的R值
        /// </summary>
        public ushort Red;
        /// <summary>
        /// 获取或设置顶点RGB颜色中的G值
        /// </summary>
        public ushort Green;
        /// <summary>
        /// 获取或设置顶点RGB颜色中的B值
        /// </summary>
        public ushort Blue;
        /// <summary>
        /// 获取或设置顶点颜色的Alpha透明度
        /// </summary>
        public ushort Alpha;

        public TRIVERTEX(int x, int y, Color color)
            : this(x, y, color.R, color.G, color.B, color.A)
        {
        }

        public TRIVERTEX(
            int x, int y,
            ushort red, ushort green, ushort blue,
            ushort alpha)
        {
            this.x = x;
            this.y = y;
            this.Red = (ushort)(red << 8);
            this.Green = (ushort)(green << 8);
            this.Blue = (ushort)(blue << 8);
            this.Alpha = (ushort)(alpha << 8);
        }
    }
}
